home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Demos / Bowers Development / AppMaker 2.0b5 / Examples / Procedural / Gadgets / Sliders.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-03-19  |  3.7 KB  |  159 lines  |  [TEXT/MMCC]

  1. /* Sliders.c */
  2. /* Created 01/01/95 12:01 PM by AppMaker */
  3.  
  4. #include <Types.h>
  5. #include <Quickdraw.h>
  6. #include <Controls.h>
  7. #include <Dialogs.h>
  8. #include <Events.h>
  9. #include <Lists.h>
  10. #include <Menus.h>
  11. #include <Resources.h>
  12. #include <TextEdit.h>
  13. #include <ToolUtils.h>
  14. #include "ResourceDefs.h"
  15. #include "Globals.h"
  16. #include "Miscellany.h"
  17. #include "Scrolling.h"
  18. #include "WindowAids.h"
  19. #include "GadgetsData.h"
  20. #include "Sliders.h"
  21.  
  22. #define VerticalScroll        1
  23. #define SliderScroll        2
  24. #define SpinnerScroll        3
  25. #define HorizontalScroll        4
  26. #define PictSliderScroll        5
  27.  
  28.  
  29. /*----------*/
  30. void OpenSliders    (FSSpec*    fileSpec,
  31.                          short        fRefNum)
  32. {
  33.     WindowPtr        newWindow;
  34.     Rect            bounds;
  35.  
  36.     newWindow = GetWindow (WIND_Sliders);
  37.     if (fileSpec->name [0] != 0) {
  38.         SetWTitle (newWindow, fileSpec->name);
  39.     }
  40.     SetPort (newWindow);
  41.     SetNewInfo (newWindow);
  42.     cur->vScroll = nil;
  43.     cur->hScroll = nil;
  44.     cur->fileNum    = fRefNum;
  45.     cur->dirty        = false;
  46.     cur->filename    = NewString (fileSpec->name);
  47.     cur->windowKind = WSliders;
  48.     ((WindowPeek) curWindow)->windowKind = userKind + WSliders;
  49.     cur->witlHandle = GetResource ('Witl', WIND_Sliders);
  50.     cur->wictHandle = GetResource ('Wict', WIND_Sliders);
  51.  
  52.         cur->VerticalHandle = GetNewControl (CNTL_Vertical, newWindow);
  53.         cur->SliderHandle = GetNewControl (CNTL_Slider, newWindow);
  54.         cur->SpinnerHandle = GetNewControl (CNTL_Spinner, newWindow);
  55.         cur->HorizontalHandle = GetNewControl (CNTL_Horizontal, newWindow);
  56.         cur->PictSliderHandle = GetNewControl (CNTL_PictSlider, newWindow);
  57.     cur->text = nil;
  58.  
  59.  
  60.     } /*OpenSliders*/
  61.  
  62.     /*----------*/
  63.     void CloseSliders    (void)
  64.     {
  65.  
  66.     DisposHandle ((Handle) cur->filename);
  67.     DiscardInfo (curWindow);
  68. } /*CloseSliders*/
  69.  
  70. /*----------*/
  71. void ControlSliders  (ControlHandle        whichControl,
  72.                          short                whichPart,
  73.                          Point                where)
  74. {
  75.     Rect            bounds;
  76.  
  77.     if (whichControl == cur->VerticalHandle) {
  78.         TrackScroll (cur->VerticalHandle, whichPart, where, nil);
  79.     }
  80.     if (whichControl == cur->SliderHandle) {
  81.         TrackScroll (cur->SliderHandle, whichPart, where, nil);
  82.     }
  83.     if (whichControl == cur->SpinnerHandle) {
  84.         TrackScroll (cur->SpinnerHandle, whichPart, where, nil);
  85.     }
  86.     if (whichControl == cur->HorizontalHandle) {
  87.         TrackScroll (cur->HorizontalHandle, whichPart, where, nil);
  88.     }
  89.     if (whichControl == cur->PictSliderHandle) {
  90.         TrackScroll (cur->PictSliderHandle, whichPart, where, nil);
  91.     }
  92.  
  93. } /*ControlSliders*/
  94.  
  95. /*----------*/
  96. void MouseInSliders    (Point        where,
  97.                          short        modifiers)
  98. {
  99.     Rect            bounds;
  100.  
  101.  
  102. } /*MouseInSliders*/
  103.  
  104. /*----------*/
  105. void TypeInSliders   (char        ch)
  106. {
  107.     if (cur->text == nil) {
  108.         SysBeep (1);
  109.     } else {
  110.         TEKey (ch, cur->text);
  111.         cur->dirty = true;
  112.     }
  113. } /*TypeInSliders*/
  114.  
  115. /*----------*/
  116. void UpdateSliders (void)
  117. {
  118.     Rect            bounds;
  119.  
  120.     SetWFont (VerticalScroll);
  121.     Draw1Control (cur->VerticalHandle);
  122.     SetWFont (SliderScroll);
  123.     Draw1Control (cur->SliderHandle);
  124.     SetWFont (SpinnerScroll);
  125.     Draw1Control (cur->SpinnerHandle);
  126.     SetWFont (HorizontalScroll);
  127.     Draw1Control (cur->HorizontalHandle);
  128.     SetWFont (PictSliderScroll);
  129.     Draw1Control (cur->PictSliderHandle);
  130.     DrawClippedGrow (-15, -15);
  131. } /*UpdateSliders*/
  132.  
  133. /*----------*/
  134. void ActivateSliders    (Boolean    activate)
  135. {
  136.     EnableControl (cur->VerticalHandle, activate);
  137.     EnableControl (cur->SliderHandle, activate);
  138.     EnableControl (cur->SpinnerHandle, activate);
  139.     EnableControl (cur->HorizontalHandle, activate);
  140.     EnableControl (cur->PictSliderHandle, activate);
  141.  
  142.     DrawClippedGrow (-15, -15);
  143. } /*ActivateSliders*/
  144.  
  145. /*----------*/
  146. void ResizeSliders    (void)
  147. {
  148.     /* application-specific code to resize items in window */
  149. } /*ResizeSliders*/
  150.  
  151. /*----------*/
  152. pascal void ScrollSliders    (short        newValue,
  153.                                  short        oldValue)
  154. {
  155.     /* application-specific code to scroll window */
  156. } /*ScrollSliders*/
  157.  
  158. /* Sliders */
  159.